EditInfomationPanel = function(obj){
	var js_fckname  = "content1";
	window.CKEDITOR.basePath = __ctxPath+'/assert/ckeditor/';
	var i = 0;
	var _instance = CKEDITOR.instances[js_fckname];
	if(_instance){
		window.CKEDITOR.remove(_instance);
	}
	var editor = new Ext.form.CKEditor({
		xtype : 'ckeditor',
		id	  : js_fckname,
		name  : 'content',
		width : '90%'
	});
	
	//选择索引词
	var keywordstore = new Ext.data.JsonStore(
		{
			data:[],
			fields:['keyword','kid']
		}
	);
	var selectorKeyWord = new Ext.ux.form.SuperBoxSelect({
    		value:'1,0',
			editable :false,
		    allowBlank:false,
		    xtype:'superboxselect',
		    fieldLabel: '索引词条',
		    emptyText:'请选择索引词',
		    blankText:'必须选择索引词',
		    resizable: true,
		    readOnly:true,
		    name: 'keywords',
		    hiddenName:'keywords',
		    width:400,
		    height:'auto',
		    anchor:'98%',
		    store: keywordstore,
		    mode: 'local',
		    displayField: 'keyword',
		    displayFieldTpl: '{keyword}',
		    valueField: 'kid',
		    forceSelection : true,
			allowQueryAll : false
    });
    //选择索引词
	var topicstore = new Ext.data.JsonStore(
		{
			data:[],
			fields:['title','tid']
		}
	);
    //
    var selectorTopic = new Ext.ux.form.SuperBoxSelect({
    		value:'1,0',
			editable :false,
		    allowBlank:false,
		    xtype:'superboxselect',
		    fieldLabel: '栏目标题',
		    emptyText:'请选择栏目',
		    blankText:'必须选择栏目',
		    resizable: true,
		    readOnly:true,
		    name: 'topicids',
		    hiddenName:'topicids',
		    width:400,
		    height:'auto',
		    anchor:'98%',
		    store: topicstore,
		    mode: 'local',
		    displayField: 'title',
		    displayFieldTpl: '{title}',
		    valueField: 'tid',
		    forceSelection : true,
			allowQueryAll : false
    });
	var form = new Ext.form.FormPanel(
		{
			frame:true,
//			width:500,
			autoWidth:true,
			items:[
				{
					xtype:'textfield',
					anchor:'90%',
					name:'title',
					fieldLabel:'信息标题'
				},{
					xtype:'textfield',
					anchor:'90%',
					name:'secondtitle',
					fieldLabel:'副信息'
				},{
	                	layout:'column',
	                	items:[
	                		{
	                			columnWidth:.7,
	                			layout:'form',
//	                			labelWidth:40,
	                			items:[
	                				selectorTopic
	                			]
	                		},{
	                			columnWidth:.3,
	                			layout:'form',
	                			items:[
	                				{
	                					xtype:'button',
	                					iconCls:'tab',
	                					text:'选择栏目',
	                					height:30,
	                					handler:function(){
	                						var _wintopic = new TopicWindow();
	                						_wintopic.show();
	                						_wintopic.on('submit',
	                							function(wintopic,datas,topicids){
	                								/*alert(datas);
	                								alert(topicids.join(','));*/
	                								var _store = selectorTopic.getStore();
										       			_store.loadData(datas);
										       			selectorTopic.setValue(topicids.join(','));
										       			wintopic.close();
	                							}
	                						);
	                					}
	                				}
	                			]
	                		}]
	            },
				editor,
				{
					layout:'column',
					items:[
						{
							//是否为焦点
							columnWidth:.3,
					        bodyStyle: 'padding-right:5px;',
					        layout: 'form',
					        items: [
					        	{
					        		xtype: 'radiogroup',
					        		anchor:'65%',
						            fieldLabel: '是否焦点',
						            listeners:{
						            	'change':function(radiogroup,radio){
						            		if(radio.inputValue==1){
						            			SX.Util.msg('系统提示','请点击焦点图片按钮编辑焦点图片');
						            			Ext.getCmp('img-detail').setVisible(true);
						            			form.buttons[0].setVisible(true);
						            		}else{
						            			form.buttons[0].setVisible(false);
						            		}
						            		
						            	}
						            },
						            items: [
						                {boxLabel: '是', name: 'foucestopic', inputValue: 1},
						                {boxLabel: '否', name: 'foucestopic', inputValue: 0, checked: true}
						            ]
					        	}
					        ]
						},{
							//是否置顶
							columnWidth:.3,
					        bodyStyle: 'padding-right:5px;',
					        layout: 'form',
					        items: [
					        	{
									xtype: 'radiogroup',
									anchor:'65%',
						            fieldLabel: '是否置顶',
						            items: [
						                {boxLabel: '是', name: 'gototopic', inputValue: 1},
						                {boxLabel: '否', name: 'gototopic', inputValue: 0, checked: true}
						            ]
					            }
				            ]
						},{
							//是否修改样式指加粗或变红
							columnWidth:.3,
					        bodyStyle: 'padding-right:5px;',
					        layout: 'form',
					        items: [
					        	{
										xtype: 'radiogroup',
										anchor:'65%',
							            fieldLabel: '是否特殊样式',
							            items: [
							                {boxLabel: '是', name: 'specialstyle', inputValue: 1},
							                {boxLabel: '否', name: 'specialstyle', inputValue: 0, checked: true}
							            ]
					            }
				            ]
						}
					]
				},
				{
					xtype:'panel',
					id:'img-detail',
					width:200,
					height:90,
					hidden:true,
					autoHeight:true,
					html:'<h1>选择焦点图片后出现在下面!</h1><br/><br/>'
				},
				{
	                	layout:'column',
	                	items:[
	                		{
	                			columnWidth:.7,
	                			layout:'form',
//	                			labelWidth:40,
	                			items:[
	                				selectorKeyWord
	                			]
	                		},{
	                			columnWidth:.3,
	                			layout:'form',
	                			items:[
	                				{
	                					xtype:'button',
	                					iconCls:'key',
	                					text:'选择索引词',
	                					height:30,
	                					handler:function(){
	                						var winkeywords = new KeyWordsWindow();
	                						winkeywords.show();
	                						winkeywords.on('submit',
	                							function(winkeywords,datas,kids){
	                								var _store = selectorKeyWord.getStore();
										       			_store.loadData(datas);
										       			selectorKeyWord.setValue(kids.join(','));
										       			winkeywords.close();
	                							}
	                						);
	                					}
	                				}
	                			]
	                		}]
	            },{
					xtype:'textfield',
					anchor:'90%',
					name:'shortcutnote',
					fieldLabel:'链接简述'
				},{
					xtype:'panel',
					id:'attachment-detail',
					width:600,
					height:90,
//					hidden:true,
					autoHeight:true,
					html:'<h1>文章附件</h1><br/><br/>'
				},{
					xtype:'hidden',
					name:'fouceimgid'
				},{
					xtype:'hidden',
					name:'aid'
				},{
					xtype:'hidden',
					name:'uid',
					value:userinfo.uid
				}
			],
			buttons:[
				{
					text:'焦点图片',
					iconCls:'picture',
					hidden:true,
					handler:function(){
						var imagewin = new ImageChooseWindow();
						imagewin.show();
						imagewin.on('selectimage',function(win,data){
							var detailsTemplate = new Ext.XTemplate(
								'<div class="details">',
									'<tpl for=".">',
										'<img src="{fvaluepath}\/{fvaluename}" ><div class="details-info">',
										'<b>图片名称:&nbsp;</b>',
										'<span>{fdisplayname}</span>',
										'</div>',
									'</tpl>',
								'</div>'
							);
							var detailEl = Ext.getCmp('img-detail').body;
							detailEl.hide();
				            detailsTemplate.overwrite(detailEl, data);
				            detailEl.slideIn('l', {stopFx:true,duration:.2});
				            //给表单里面的fouceimgid隐藏域赋值
				            form.getForm().findField('fouceimgid').setValue(data.id);
				            imagewin.close();
						});
					}
				},
				{
					text:'附件上传',
					iconCls:'attach',
					handler:function(){
						var obj = {
							title:'附件上传',
							url:__ctxPath+'/back/article/uploadfileinfo.html',
							iconcls:'attach'
						};
						var attachmentwin = new AttachmentWindow(obj);
						attachmentwin.show();
					}
				},
				{
					text:'确定',
					iconCls:'confirm',
					handler:function(){
						var me = this;
						form.getForm().submit(
							{
								url:__ctxPath+'/back/article/editinfo.html',
								params:{},
								waitTitle:'系统提示',
								waitMsg:'正在提交数据请稍后!', 
								method:'POST',
								success:function(f,action){
									SX.Util.msg('系统提示','编辑成功!');
									me.destroy();
								},
								failure:function(f,action){
								
								}
							}
						);
					},
					scope:this
				},{
					text:'取消',
					iconCls:'cancel',
					handler:function(){
						
					}
				}
			]
		}
	);
	var attachments;
	form.getForm().load(
		{
			url:__ctxPath+'/back/article/findarticleinfobyid.html',
			params:{aid:obj.get('aid')},
			method:'POST',
			success:function(f,action){
				var data = action.result.data;
				//keywordsinfo
				var kids = [];
				if(data.keywordlist){
					var keywords = data.keywordlist;
					for (var i = 0; i < keywords.length; i++) {
						var keyword = keywords[i];	
						kids.push(keyword.kid);
					}	
					var _store = selectorKeyWord.getStore();
		       			_store.loadData(data.keywordlist);
		       			selectorKeyWord.setValue(kids);
				}
				
				//titleinfosetting
	       		var titleids = [];
	       		if(data.titles){
	       			var titles = data.titles;
	       			for (var i = 0; i < titles.length; i++) {
						var title = titles[i];	
						titleids.push(title.tid);
					}
					var _titlestore = selectorTopic.getStore();
		       			_titlestore.loadData(titles);
		       			selectorTopic.setValue(titleids.join(','));
	       		}
	       		//焦点图片进行设置
	       		if(data.fourceimages){
	       			var fourceimages = data.fourceimages;
	       			if(fourceimages.length>0){
	       				var fourceimage = fourceimages[0];
	       				var detailsTemplate = new Ext.XTemplate(
							'<div class="details">',
								'<tpl for=".">',
									'<img src="{fvaluepath}\/{fvaluename}" ><div class="details-info">',
									'<b>图片名称:&nbsp;</b>',
									'<span>{fdisplayname}</span>',
									'</div>',
								'</tpl>',
							'</div>'
						);
						var detailEl = Ext.getCmp('img-detail').body;
						detailEl.hide();
			            detailsTemplate.overwrite(detailEl, fourceimage);
			            detailEl.slideIn('l', {stopFx:true,duration:.2});
			            //给表单里面的fouceimgid隐藏域赋值
			            form.getForm().findField('fouceimgid').setValue(fourceimage.id);
	       			}
	       		}
	       		//加载附件信息
	       		if(data.attachment){
	       			 attachments = data.attachment;
	       			if(attachments.length>0){
	       				var attachmentTemplate = new Ext.XTemplate(
							'<div>',
								'<tpl for=".">',
									'{fdisplayname}&nbsp;&nbsp;',
									'<a href="#{fid}" onclick="deleteAttachment({fid})" style="text-decoration: underline;">删除</a>&nbsp;&nbsp;',
									'<a href="#{fid}" onclick=downloadAttachment("{fdisplayname}","{fvaluename}","{fvaluepath}") >下载</a>',
									'<br/>',
								'</tpl>',
							'</div>'
						);
						var detailEl = Ext.getCmp('attachment-detail').body;
//						detailEl.hide();
			            attachmentTemplate.overwrite(detailEl, attachments);
	       			}
	       		}
			},
			failure:function(form,action){
				
			}
		}
	);
	//下载附件
	window.downloadAttachment = function(realname, filename, path){
		var form = document.createElement('form');
		form.action = __ctxPath+'/back/article/downloadfile.html';
		form.name = 'form1';
		form.method = 'POST';
		var realInput = document.createElement('input');
			realInput.name = 'realname';
			realInput.type = 'hidden';
			realInput.value = realname;
			form.appendChild(realInput);
		var fileInput = document.createElement('input');
			fileInput.name = 'filename';
			fileInput.type = 'hidden';
			fileInput.value = filename;
			form.appendChild(fileInput);
		var pathInput = document.createElement('input');
			pathInput.name = 'path';
			pathInput.type = 'hidden';
			pathInput.value = path;
			form.appendChild(pathInput);
		document.body.appendChild(form);
		form.submit();
		/*var downloadconfig = {
			url:__ctxPath+'/back/article/downloadfile.html',
			params:{realname:realname, filename:filename, path:path},
			success:function(){},
			failure:function(){}
		}
		Ext.Ajax.request(downloadconfig);*/
	}
	
	//删除附件
	window.deleteAttachment = function(fid){
		Ext.MessageBox.confirm('系统提示','是否确定删除此附件!',
			function(btn){
				if(btn=='yes'){
					Ext.Ajax.request(
						{
							params:{fid:fid,aid:obj.get('aid')},
							url:__ctxPath+'/back/article/deletearticleattachments.html',
							method:'POST',
							success:function(resp,option){
								var resultobj = Ext.decode(resp.responseText);
								if(resultobj.success==true){
									for (var i = 0; i < attachments.length; i++) {
										var _attach = attachments[i];
										if(_attach.fid==fid){
											attachments.remove(_attach);
											break;
										}
									}
									var attachmentTemplate = new Ext.XTemplate(
										'<div>',
											'<tpl for=".">',
												'{fdisplayname}&nbsp;&nbsp;',
												'<a href="#{fid}" onclick="deleteAttachment({fid})" style="text-decoration: underline;">删除</a>&nbsp;&nbsp;',
												'<a href="{fvaluepath}\/{fvaluename}" target="_blank" >下载</a>',
												'<br/>',
											'</tpl>',
										'</div>'
									);
									var detailEl = Ext.getCmp('attachment-detail').body;
							        attachmentTemplate.overwrite(detailEl, attachments);
								}else{
									SX.Util.msg('系统提示','删除附件失败!');	
								}
							},
							failure:function(resp,option){
								SX.Util.msg('系统提示','删除附件失败!');
							}
						}
					);
				}
			}
		);
		
		
	}
	var config = {
		title:'编辑信息',
		iconCls:'edit',
		id:'EditInfomationPanel',
		layout:"form",
		items:[form]
	}
	EditInfomationPanel.superclass.constructor.call(this,config);
}
Ext.extend(EditInfomationPanel,Ext.Panel);